home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #43 (Apr 89) / Designer CDEF Code / HandleTheMenus.Pas < prev    next >
Pascal/Delphi Source File  |  1989-01-06  |  2KB  |  68 lines

  1. UNIT HandleTheMenus;
  2.  
  3. INTERFACE
  4.  
  5.     USES
  6.         AboutDialog, ExampleWindow, InitTheMenus;
  7.  
  8.     PROCEDURE Handle_My_Menu (VAR doneFlag : boolean;
  9.                                     theMenu, theItem : integer); {Handle menu selection}
  10.  
  11. IMPLEMENTATION
  12.  
  13.     PROCEDURE Handle_My_Menu;             {Handle menu selections realtime}
  14.         CONST
  15.             L_Apple = 201;                    {Menu list}
  16.             C_About = 1;
  17.             L_File = 202;                     {Menu list}
  18.             C_Quit = 1;
  19.         VAR
  20.             DNA : integer;                      {For opening DAs}
  21.             BoolHolder : boolean;               {For SystemEdit result}
  22.             DAName : Str255;                    {For getting DA name}
  23.             SavePort : GrafPtr;                 {Save current port when opening DAs}
  24.  
  25.     BEGIN                               {Start of procedure}
  26.  
  27.         CASE theMenu OF                 {Do selected menu list}
  28.  
  29.             L_Apple : 
  30.                 BEGIN
  31.                     CASE theItem OF             {Handle all commands in this menu list}
  32.                         C_About : 
  33.                             BEGIN
  34.                                 D_AboutDialog;        {Call a dialog for this menu selection}
  35.                             END;
  36.                         OTHERWISE                 {Handle the DAs}
  37.                             BEGIN                   {Start of Otherwise}
  38.                                 GetPort(SavePort);    {Save the current port}
  39.                                 GetItem(AppleMenu, theItem, DAName); {Get the name of the DA selected}
  40.                                 DNA := OpenDeskAcc(DAName); {Open the DA selected}
  41.                                 SetPort(SavePort);    {Restore to the saved port}
  42.                             END;                    {End of Otherwise}
  43.  
  44.                     END;                        {End of item case}
  45.                 END;                          {End for this list}
  46.  
  47.             L_File : 
  48.                 BEGIN
  49.                     CASE theItem OF             {Handle all commands in this menu list}
  50.                         C_Quit : 
  51.                             BEGIN
  52.                                 doneFlag := TRUE;
  53.                             END;
  54.                         OTHERWISE
  55.                             ;
  56.  
  57.                     END;                        {End of item case}
  58.                 END;                          {End for this list}
  59.  
  60.             OTHERWISE
  61.                 ;
  62.  
  63.         END;                              {End for lists}
  64.  
  65.         HiliteMenu(0);                    {Turn menu selection off}
  66.     END;                                {End of procedure Handle_My_Menu}
  67.  
  68. END.                                    {End of unit}